
#include "stdafx.h"


enum MainRetCodes
{
	RetOK,
	RetError
};


int test_regex_check( int argc, char* argv[ ] )
{
	if( argc < 3 )
	{
		printf( "%s( ) arguments are:\n\t<wildcard_pattern> <literal_1> [ <literal_2> ... <literal_N> ]\n", argv[ 0 ] );

		return RetError;
	}


	for( int i = 2; i < argc; ++i )
		printf( "{%s} matches {%s} ?\t: %d\n", argv[ 1 ], argv[ i ], regex_check( argv[ 1 ], argv[ i ] ) );


	return RetOK;
}


int main( int argc, char* argv[ ] )
{
	struct
	{
		char* name;
		int( *function )( int argc, char* argv[ ] );
	}
	test_functions[ ] =
	{
		{ "regex_check", test_regex_check },
		{ nullptr, nullptr }
	};


	if( argc == 1 )
		goto print_usage;


	for( int i = 0; test_functions[ i ].function; ++i )
		if( _stricmp( argv[ 1 ], test_functions[ i ].name ) == 0 )
			return test_functions[ i ].function( argc - 1, argv + 1 );


print_usage:
	printf( "Usage:\n\t%s <function_to_be_tested> [argument(s)]\n\n", argv[ 0 ] );
	printf( "And the functions are:\n" );


	for( int i = 0; test_functions[ i ].function; ++i )
		printf( "\t%s( )\n", test_functions[ i ].name );


	return RetError;
}
